home *** CD-ROM | disk | FTP | other *** search
- //***********************************************************************
- //
- // MainFrame.cpp
- //
- //***********************************************************************
-
- #define OEMRESOURCE
-
- #include <afxwin.h>
- #include <afxext.h>
- #include "Resource.h"
- #include "CLine.h"
- #include "MainFrame.h"
- #include "Paint5Doc.h"
-
- IMPLEMENT_DYNCREATE (CMainFrame, CFrameWnd)
-
- BEGIN_MESSAGE_MAP (CMainFrame, CFrameWnd)
- ON_WM_CREATE ()
- ON_WM_MEASUREITEM ()
- ON_WM_DRAWITEM ()
- END_MESSAGE_MAP ()
-
- int CMainFrame::OnCreate (LPCREATESTRUCT lpcs)
- {
- if (CFrameWnd::OnCreate (lpcs) == -1)
- return -1;
-
- CMenu* pMenu = GetMenu ();
- for (int i=0; i<8; i++)
- pMenu->ModifyMenu (ID_COLOR_BLACK + i,
- MF_BYCOMMAND | MF_OWNERDRAW, ID_COLOR_BLACK + i);
- return 0;
- }
-
- BOOL CMainFrame::OnCreateClient (LPCREATESTRUCT lpcs,
- CCreateContext* pContext)
- {
- return m_wndSplitter.Create (this, 2, 2, CSize (1, 1), pContext);
- }
-
- void CMainFrame::OnMeasureItem (int nIDCtl, LPMEASUREITEMSTRUCT lpmis)
- {
- lpmis->itemWidth = ::GetSystemMetrics (SM_CYMENU) * 4;
- lpmis->itemHeight = ::GetSystemMetrics (SM_CYMENU);
- }
-
- void CMainFrame::OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpdis)
- {
- BITMAP bm;
- CBitmap bitmap;
- bitmap.LoadOEMBitmap (OBM_CHECK);
- bitmap.GetObject (sizeof (bm), &bm);
-
- CDC dc;
- dc.Attach (lpdis->hDC);
-
- CBrush* pBrush = new CBrush (::GetSysColor ((lpdis->itemState &
- ODS_SELECTED) ? COLOR_HIGHLIGHT : COLOR_MENU));
- dc.FrameRect (&(lpdis->rcItem), pBrush);
- delete pBrush;
-
- if (lpdis->itemState & ODS_CHECKED) {
- CDC dcMem;
- dcMem.CreateCompatibleDC (&dc);
- CBitmap* pOldBitmap = dcMem.SelectObject (&bitmap);
-
- dc.BitBlt (lpdis->rcItem.left + 4, lpdis->rcItem.top +
- (((lpdis->rcItem.bottom - lpdis->rcItem.top) -
- bm.bmHeight) / 2), bm.bmWidth, bm.bmHeight, &dcMem,
- 0, 0, SRCCOPY);
-
- dcMem.SelectObject (pOldBitmap);
- }
-
- pBrush = new CBrush (CPaintDoc::m_crColors[lpdis->itemID -
- ID_COLOR_BLACK]);
- CRect rect = lpdis->rcItem;
- rect.DeflateRect (6, 4);
- rect.left += bm.bmWidth;
- dc.FillRect (rect, pBrush);
- delete pBrush;
-
- dc.Detach ();
- }
-